<!--conf
<sample in_favorites="false">
               <product version="1.4" edition="std"/>
                       <modifications>
                               <modified date="070101"/>
                       </modifications>
               </sample>
 --> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Using Grid API Methods</title>
	
</head>

<body>
<link rel='STYLESHEET' type='text/css' href='../common/style.css'>
<table cellspacing="0" cellpadding="0" class="sample_header" border="0">
	<tr valign="middle">
		<!-- COMPONENT ICON -->
		<td width="40" align="center"><img src="../common/dhtmlxgrid_icon.gif" border="0"></td>
		<!-- COMPONENT NAME -->
		<td width="150" align="left" nowrap="true">Sample: dhtmlxGrid</td>
		<!-- SAMPLE TITLE -->
		<td width="0" align="left" nowrap><b>Using Grid API Methods</b></td>
		<!-- LINK TO COMPONENT PAGE -->
		<td width="0" align="right"><a href="http://www.dhtmlx.com/docs/products/dhtmlxGrid/index.shtml">dhtmlxGrid main page</a></td>
		<!-- CLOSE BUTTON -->
		<td width="50"><div class="sample_close"><a href="javascript:void(0);" onclick="self.close();"><img src="../common/sample_close.gif" width="14" height="14" border="0" alt="X"></a></div></td>
	</tr>
</table>
	
	
	<p>Manipulate grid content, appearance and functionality using wide range of Grid API methods</p>
	<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
	
	<script  src="../../codebase/dhtmlxcommon.js"></script>
	<script  src="../../codebase/dhtmlxgrid.js"></script>		
	<script  src="../../codebase/dhtmlxgridcell.js"></script>	
	<table width="600">
		<tr>
			<td width="50%" valign="top">
				<div id="gridbox" width="100%" height="250px" style="background-color:white;"></div>
			</td>
			<td valign="top">
				<div id="gridbox2" style="width:250px;height:250px;border:1px solid blue;"></div>
			</td>
		</tr>
		<tr>
			<td>
				<a href="javascript:mygrid.clearAll()">clearAll</a><br>
				<a href="javascript:mygrid.setHeaderCol(1,'New Header')">setHeaderCol</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else  mygrid.copyRowContent(mygrid.getRowId(0),mygrid.getSelectedId())">copyRowContent (ex.:from first to selected)</a><br>
				<a href="javascript:mygrid.clearSelection()">clearSelection</a><br>
				<a href="javascript:mygrid.setSelectedRow(mygrid.getRowId(1))">setSelectedRow (ex.:second)</a><br>
				<a href="javascript:mygrid.setEditable(!mygrid.isEditable)">setEditable (ex.:on/off)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else  mygrid.setUserData(mygrid.getSelectedId(),'ud2','this value was set with script')">setUserData (ex.: to selected row)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else alert(mygrid.getUserData(mygrid.getSelectedId(),'ud2'))">getUserData (ex.: of selected row)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else alert(mygrid.cells(mygrid.getSelectedId(),mygrid.getSelectedCellIndex()).getValue())">cells.getValue (ex.: of selected cell)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else alert(mygrid.cells2(mygrid.getRowIndex(mygrid.getSelectedId()),mygrid.getSelectedCellIndex()).getValue())">cells2.getValue (ex.: of selected cell)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.moveRowDown(mygrid.getSelectedId())">moveRowDown (ex.:selected)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.moveRowUp(mygrid.getSelectedId())">moveRowUp (ex.:selected)</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.getColumnCount())">getColumnCount</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.getRowsNum())">getRowsNum</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.getAllItemIds())">getAllItemIds</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.isItemExists('14'))">isItemExists (with id=14)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.setRowTextStyle(mygrid.getSelectedId(),'color:red;font-family:verdana;font-size:14px;')">setRowTextStyle (ex.:selected)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.setRowTextBold(mygrid.getSelectedId())">setRowTextBold (ex.:selected)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.setRowTextNormal(mygrid.getSelectedId())">setRowTextNormal (ex.:selected)</a><br>
			</td>
			<td>
				<a href="javascript:void(0)" onclick="mygrid.setColumnIds('A,B')">setColumnIds (A,B)</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.getColumnId(0))">getColumnId (ex.:first)</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.getColIndexById('B'))">getColIndexById (ex.: B)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.setRowId(mygrid.getRowIndex(mygrid.getSelectedId()),'newid')">setRowId (ex.: selected)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else alert(mygrid.getRowId(mygrid.getRowIndex(mygrid.getSelectedId())))">getRowId (ex.:selected)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else alert(mygrid.getRowIndex(mygrid.getSelectedId()))">getRowIndex (ex.:selected)</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else alert(mygrid.getColWidth(mygrid.getSelectedCellIndex()))">getColWidth (ex.:of selected cell)</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.getSelectedCellIndex())">getSelectedCellIndex</a><br>
				<a href="javascript:void(0)" onclick="alert(mygrid.getSelectedId())">getSelectedId</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.deleteSelectedItem()">deleteSelectedItem</a><br>
				<a href="javascript:void(0)" onclick="if(!mygrid.getSelectedId()) alert('Please, select any row'); else mygrid.deleteRow(mygrid.getSelectedId())">deleteRow (ex.: selected)</a><br>
				<a href="javascript:void(0)" onclick="mygrid.setMultiselect(!mygrid.selMultiRows)">setMultiselect (on/off)</a><br>
				<a href="javascript:void(mygrid.addRow(mygrid.getUID(),'text 1,text 2',1))">addRow (ex.:second position)</a><br>
				<a href="javascript:void(0)" onclick="mygrid.selectRow(0)">selectRow (ex.:first one)</a><br>
				<a href="javascript:void(0)" onclick="mygrid.selectCell(1,1)">selectCell (ex.: second cell of second row)</a><br>
				<a href="javascript:void(0)" onclick="mygrid.attachToObject(document.getElementById('gridbox2'))">attachToObject</a><br>
			</td>
		</tr>
	</table>

<div class='sample_code'><div class="hl-main"><pre><span class="hl-code"> 
    </span><span class="hl-comment">//</span><span class="hl-comment">...See Documentation for complete list of Grid API Methods and some details of their usage</span><span class="hl-comment"></span><span class="hl-code">
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.clearAll()</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">clearAll</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setHeaderCol(1,'New Header')</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setHeaderCol</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.copyRowContent(mygrid.getRowId(0),mygrid.getSelectedId())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">copyRowContent</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">from</span><span class="hl-code"> </span><span class="hl-identifier">first</span><span class="hl-code"> </span><span class="hl-identifier">to</span><span class="hl-code"> </span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.clearSelection()</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">clearSelection</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setSelectedRow(mygrid.getRowId(1))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setSelectedRow</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">second</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setEditable(!mygrid.isEditable)</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setEditable</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">on</span><span class="hl-code">/</span><span class="hl-identifier">off</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setUserData(mygrid.getSelectedId(),'ud2','this value was set with script')</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setUserData</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">to</span><span class="hl-code"> </span><span class="hl-identifier">selected</span><span class="hl-code"> </span><span class="hl-identifier">row</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getUserData(mygrid.getSelectedId(),'ud2'))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getUserData</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">of</span><span class="hl-code"> </span><span class="hl-identifier">selected</span><span class="hl-code"> </span><span class="hl-identifier">row</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.cells(mygrid.getSelectedId(),mygrid.getSelectedCellIndex()).getValue())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">cells</span><span class="hl-code">.</span><span class="hl-identifier">getValue</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">of</span><span class="hl-code"> </span><span class="hl-identifier">selected</span><span class="hl-code"> </span><span class="hl-identifier">cell</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.cells2(mygrid.getRowIndex(mygrid.getSelectedId()),mygrid.getSelectedCellIndex()).getValue())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">cells2</span><span class="hl-code">.</span><span class="hl-identifier">getValue</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">of</span><span class="hl-code"> </span><span class="hl-identifier">selected</span><span class="hl-code"> </span><span class="hl-identifier">cell</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.moveRowDown(mygrid.getSelectedId())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">moveRowDown</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.moveRowUp(mygrid.getSelectedId())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">moveRowUp</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getColumnCount())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getColumnCount</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getRowsNum())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getRowsNum</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getAllItemIds())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getAllItemIds</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.isItemExists('14'))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">isItemExists</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-reserved">with</span><span class="hl-code"> </span><span class="hl-identifier">id</span><span class="hl-code">=</span><span class="hl-number">14</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setRowTextStyle(mygrid.getSelectedId(),'color:red;font-family:verdana;font-size:14px;')</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setRowTextStyle</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setRowTextBold(mygrid.getSelectedId())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setRowTextBold</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setRowTextNormal(mygrid.getSelectedId())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setRowTextNormal</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setColumnIds('A,B')</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setColumnIds</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">A</span><span class="hl-code">,</span><span class="hl-identifier">B</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getColumnId(0))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getColumnId</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">first</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getColIndexById('B'))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getColIndexById</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">B</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setRowId(mygrid.getRowIndex(mygrid.getSelectedId()),'newid')</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setRowId</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getRowId(mygrid.getRowIndex(mygrid.getSelectedId())))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getRowId</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getRowIndex(mygrid.getSelectedId()))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getRowIndex</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getColWidth(mygrid.getSelectedCellIndex()))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getColWidth</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">of</span><span class="hl-code"> </span><span class="hl-identifier">selected</span><span class="hl-code"> </span><span class="hl-identifier">cell</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getSelectedCellIndex())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getSelectedCellIndex</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:alert(mygrid.getSelectedId())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">getSelectedId</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.deleteSelectedItem()</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">deleteSelectedItem</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:void(0)</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-identifier">onclick</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">mygrid.deleteRow(mygrid.getSelectedId())</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">deleteRow</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">selected</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.setMultiselect(!mygrid.selMultiRows)</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">setMultiselect</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">on</span><span class="hl-code">/</span><span class="hl-identifier">off</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:void(mygrid.addRow('x2','text 1,text 2',1))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">addRow</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">second</span><span class="hl-code"> </span><span class="hl-identifier">position</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.selectRow(0)</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">selectRow</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.:</span><span class="hl-identifier">first</span><span class="hl-code"> </span><span class="hl-identifier">one</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.selectCell(1,1)</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">selectCell</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-identifier">ex</span><span class="hl-code">.: </span><span class="hl-identifier">second</span><span class="hl-code"> </span><span class="hl-identifier">cell</span><span class="hl-code"> </span><span class="hl-identifier">of</span><span class="hl-code"> </span><span class="hl-identifier">second</span><span class="hl-code"> </span><span class="hl-identifier">row</span><span class="hl-brackets">)</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;
    &lt;</span><span class="hl-identifier">a</span><span class="hl-code"> </span><span class="hl-identifier">href</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">javascript:mygrid.attachToObject(document.getElementById('gridbox2'))</span><span class="hl-quotes">&quot;</span><span class="hl-code">&gt;</span><span class="hl-identifier">attachToObject</span><span class="hl-code">&lt;/</span><span class="hl-identifier">a</span><span class="hl-code">&gt;&lt;</span><span class="hl-identifier">br</span><span class="hl-code">&gt;</span></pre></div></div>
		
<script>
	mygrid = new dhtmlXGridObject('gridbox');
	mygrid.setImagePath("../../codebase/imgs/");
	mygrid.setHeader("Column A, Column B");
	mygrid.setInitWidths("100,250")
	mygrid.setColAlign("right,left")
	mygrid.setColTypes("dyn,ed");
	mygrid.setColSorting("str,str")
	mygrid.init();
	mygrid.loadXML("grid.xml");
</script>

<!-- FOOTER -->
<table callspacing="0" cellpadding="0" border="0" class="sample_footer"><tr><td style="padding-left: 8px;">&copy; <a href="http://www.dhtmlx.com">DHTMLX LTD</a>. All rights reserved</td></tr></table>
<!-- FOOTER -->

</body>
</html>
